package cn.wolfcode.luowowo.comment.services.impl;

import cn.wolfcode.luowowo.comment.domain.Wenda;
import cn.wolfcode.luowowo.comment.domain.WendaComment;
import cn.wolfcode.luowowo.comment.repository.WendaCommentRepository;
import cn.wolfcode.luowowo.comment.service.IWendaCommentService;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;

import java.util.ArrayList;
import java.util.List;

@Service
public class WendaCommentServiceImpl implements IWendaCommentService {

    @Autowired
    private WendaCommentRepository wendaCommentRepository;

    @Override
    public List<WendaComment> listByWendaId(String id) {
        return wendaCommentRepository.findByWendaId(id);
    }

    @Override
    public AjaxResult save(WendaComment wendaComment) {
        AjaxResult result = new AjaxResult();
        try {
            wendaCommentRepository.save(wendaComment);
        } catch (Exception e) {
            result.mark("保存评论失败");
            e.printStackTrace();
        }
        return result;
    }



}
